<?php
use Slim\Http\Request;
use Slim\Http\Response;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Container\Container;
require 'vendor/autoload.php';
date_default_timezone_set('Asia/Shanghai');
//加载配置文件
$app = new \Slim\App(C('settings'));
session_start();
//注入Eloquent依赖类
//$container = $app->getContainer();
//$container['db'] = function ($container) {
//    $capsule = new \Illuminate\Database\Capsule\Manager;
//    $capsule->addConnection($container['settings']['db']);
//    $capsule->setAsGlobal();
//    $capsule->bootEloquent();
//    return $capsule;
//};
//不使用容器注入模式,直接在全局注册连接
$capsule = new Illuminate\Database\Capsule\Manager;
// 创建链接
$capsule->addConnection(C('settings','db'));
//$capsule->setEventDispatcher(new Dispatcher(new IlluminateContainer));
// 设置全局静态可访问DB
$capsule->setAsGlobal();
// 启动Eloquent （如果只使用查询构造器，这个可以注释）
$capsule->bootEloquent();

require_once BASE_PATH_PUBLIC.'/route.php';

$app->run();
